package com.mew.slots.core.common.handler;


import com.mew.slots.core.common.messge.request.BetRequestMessage;
import com.mew.slots.core.common.messge.request.BonusRequestMessage;
import com.mew.slots.core.common.messge.request.EnterGameRequestMessage;
import com.mew.slots.core.common.messge.request.ReconnectionGameRequestMessage;
import com.zebra.remoting.config.EmptyMessage;
import com.zebra.remoting.protocol.CommandCode;
import com.zebra.remoting.protocol.CommandType;
import com.zebra.remoting.protocol.PoolType;
import com.zebra.remoting.protocol.ProcessorType;

import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;


 /**
 *   5 命令号不能使用
 */
public enum SlotsHandlerMapCmdType implements CommandCode {

    EnterRoom(9000,  ProcessorType.G_LOGIN, PoolType.EXECUTOR,  EnterGameRequestMessage.class), // "EnterRoom"
    ReconnectRoom(9001,  ProcessorType.G_RECON, PoolType.EXECUTOR, ReconnectionGameRequestMessage.class), // "EnterRoom"
    ExitRoom(9009, ProcessorType.G_EXIT, PoolType.DISRUPTOR,  EmptyMessage.class),  //返回大厅

    Bet(2000,  ProcessorType.GM, PoolType.DISRUPTOR,  BetRequestMessage.class),  //bet 返回的数据自定义
    BonusBet(2001, ProcessorType.GM, PoolType.DISRUPTOR,   BonusRequestMessage.class), //Bonus 返回的数据自定义
    JackPort(3000,ProcessorType.GM, PoolType.DISRUPTOR,  EmptyMessage.class)
    ;
     private int cmd ;
     private CommandType commandType;
     private ProcessorType processorType;
     private PoolType poolType;
     private boolean verifyType;
     private final Class request;

    SlotsHandlerMapCmdType(int cmd, ProcessorType processorType, PoolType poolType,  Class request){
        this.cmd = cmd;
        this.processorType = processorType;
        this.poolType = poolType;
        this.verifyType = true;
        this.request = request;
        this.commandType = CommandType.GAME;
    }

    @Override
    public int cmd() {
        return this.cmd;
    }

     @Override
     public ProcessorType processorType() {
         return this.processorType;
     }

     @Override
    public Class request() {
        return this.request;
    }


     @Override
     public PoolType poolType() {
         return this.poolType;
     }

     @Override
     public boolean verifyType() {
         return verifyType;
     }

     @Override
     public CommandType commandType() {
         return this.commandType;
     }


     //转换成 map
    private  static Map<Integer, CommandCode> handlerTypeMap = Arrays.stream(SlotsHandlerMapCmdType.values())
            .collect(Collectors.toMap(SlotsHandlerMapCmdType::cmd, rtype -> rtype));

    public  static SlotsHandlerMapCmdType valueOfCode(int cmd){
        return (SlotsHandlerMapCmdType) handlerTypeMap.get(cmd);
    }

    public  static Map<Integer, CommandCode> getMap(){
        return handlerTypeMap;
    }



}
